package com.todod.base.module.base.dal.mysql.protocolstandard;

import java.util.*;

import com.todod.base.framework.common.pojo.PageResult;
import com.todod.base.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.todod.base.framework.mybatis.core.mapper.BaseMapperX;
import com.todod.base.module.base.dal.dataobject.protocolstandard.ProtocolStandardDO;
import org.apache.ibatis.annotations.Mapper;
import com.todod.base.module.base.controller.admin.protocolstandard.vo.*;
import org.apache.ibatis.annotations.Update;

/**
 * 协议标准 Mapper
 *
 * @author 平台
 */
@Mapper
public interface ProtocolStandardMapper extends BaseMapperX<ProtocolStandardDO> {

    default PageResult<ProtocolStandardDO> selectPage(ProtocolStandardPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProtocolStandardDO>()
                .eqIfPresent(ProtocolStandardDO::getDeviceType, reqVO.getDeviceType())
                .eqIfPresent(ProtocolStandardDO::getSerialNumber, reqVO.getSerialNumber())
                .eqIfPresent(ProtocolStandardDO::getProtocolCode, reqVO.getProtocolCode())
                .likeIfPresent(ProtocolStandardDO::getProtocolName, reqVO.getProtocolName())
                .eqIfPresent(ProtocolStandardDO::getState, reqVO.getState())
                .betweenIfPresent(ProtocolStandardDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProtocolStandardDO::getId));
    }

    /**
     * 启用协议标准
     *
     * @param id 编号
     */
    @Update("update base_protocol_standard set state = 1   where id = #{id} ")
    public void enable(Long id);

    /**
     * 禁用协议标准
     *
     * @param id 编号
     */
    @Update("update base_protocol_standard set state = 0   where id = #{id} ")
    public void disable(Long id);

}